class Solution {
    public int countMaxOrSubsets(int[] nums) {
         int n = nums.length;
        int totalSubSets = 1 << n;  // n左移一位 或者子集数量 2^n
        Map<Integer, Integer> map = new HashMap<>();
        int max=0;
        for (int i = 0; i < totalSubSets; i++) {
            int curQuality = 0;
            for (int j = 0; j < n; j++) {
                if ((i & (1 << j)) != 0) {
                    curQuality = curQuality | nums[j];
                    max=Math.max(max,curQuality);
                }
            }
            if (map.containsKey(curQuality)) {
                map.put(curQuality, map.get(curQuality) + 1);
            } else {
                map.put(curQuality, 1);
            }
        }
        
        return map.get(max);
    }
}